package com.ruoyi.web.controller.example;

import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.example.service.StudentService;
import com.ruoyi.web.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@Anonymous
@RestController
public class StudentController {

    //ioc - 》 控制反转
    //ioc 是不需要你自己去new对象的
    @Autowired
    private StudentService service;


    //想要让controller 调用service，就需要有一个service的对象，才能够调用service对应的用法

    @GetMapping("/list")
    private String list(){
        return service.getStudents();
    }

    //需要使用postman进行测试
    @PostMapping("/user")
    public String json(@RequestBody User user) {
       return "用户的姓名是：" + user.getName() +
               "用户的学号是：" + user.getSno() +
               "用户的性别是：" + user.getGender();

    }
}
